home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / DELPHI.SWG / 0035_BDE: Writing Buffer to Disk.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  2.6 KB  |  79 lines

  1.  
  2. Product: Delphi and the Borland Database Engine
  3. Number: ?????
  4. Versions: 1.x, 2.x
  5. OS: WINDOWS 3.x, WINDOWS 95, WINDOWS NT
  6. DATE: December 7, 1995
  7. TITLE: Using DbiUseIdleTime and DbiSaveChanges.
  8.  
  9. General:
  10. =======
  11.  
  12. Changes made to a table are not written directly to disk until 
  13. the table is closed.  A power failure or system crash can 
  14. result in a loss of data, and an inconvenience.  To avoid this 
  15. loss of data, two direct Database Engine calls can be made, 
  16. both of which have the similar effects. These functions are 
  17. DbiUseIdleTime and DbiSaveChanges.
  18.  
  19. DbiSaveChanges(hDBICur):
  20. =======================
  21.  
  22. DbiSaveChanges saves to disk all the updates that are in the 
  23. buffer of the table associated with the cursor (hDBICur). It 
  24. can be called at any point. For example, one may want to make 
  25. save changes to disk every time a record is updated (add 
  26. dbiProcs to uses clause):
  27.  
  28. procedure TForm1.Table1AfterPost(DataSet: TDataSet); 
  29. begin      
  30.   DbiSaveChanges(Table1.handle);
  31. end;
  32.  
  33. This way, one does not have to worry about losing data if a 
  34. power failure or system crash occurs after a record update.
  35.  
  36. DbiSaveChanges can also be used to make a temporary table 
  37. (created by DbiCreateTempTable) permanent.
  38.  
  39. This function does NOT apply to SQL tables.
  40.  
  41. DbiUseIdleTime:
  42. ==============
  43.  
  44. DbiUseIdleTime can be called when the "Windows Message Queue" 
  45. is empty. It allows the Database Engine to save "dirty buffers" 
  46. to disk. In other words, it does what DbiSaveChanges does, but 
  47. performs the operation on ALL the tables that have been 
  48. updated. This operation however, will not necessarily occur 
  49. after every record update, because it can only be executed when 
  50. there is an idle period.
  51.  
  52. In Delphi, it can be used in this fashion (add dbiProcs to uses clause):
  53.  
  54. procedure TForm1.FormCreate(Sender: TObject);
  55. begin
  56.      Application.onIdle := UseIdle;
  57. end;
  58.  
  59. procedure Tform1.UseIdle(Sender: TObject; var Done: Boolean);
  60. begin
  61.      DbiUseIdleTime;
  62. end;
  63.  
  64.  
  65. USAGE NOTES:
  66. ===========
  67.  
  68. Using both DbiUseIdleTime and DbiSaveChanges (after every 
  69. record modification) is redundant and will result in 
  70. unnecessary function calls. If the application is one that 
  71. perfroms a great deal of record insertions or modifications in 
  72. a small period of time, it is recommended that the client 
  73. either call DbiUseIdleTime during an idle period, or call 
  74. DbiSaveChanges after a group of updates.
  75.  
  76. If not very many updates are being performed on the table, the
  77. client may choose to call DbiSaveChanges after every post or
  78. set up a timer and call DbiUseIdleTime when a timer even is generated.
  79.